#include "myhead.h"

void ExitTid()
{
    Send_Command("stop\n");
    Send_Command("q\n");
    Send_Command("quit\n");
    sleep(1);
    printf("Program exited.\n");
}

//退出
void ExitLcd()
{
    /*释放LCD的映射空间*/
	munmap(map,800*480*4);
	
	/*关闭LCD*/
	close(fd);

    //关闭触摸屏
	close(ts_fd1);

    /*关闭管道文件fifo*/
	close(fd_fifo);

    //毁掉互斥锁
	pthread_mutex_destroy(&mutex);

    //关闭触摸屏
	close(ts_fd2);
	close(ts_fd3);

    // 取消并等待每个线程退出
    pthread_cancel(tid1);
    pthread_cancel(tid2);
    pthread_cancel(tid3);
    pthread_cancel(tid4);

    pthread_join(tid1, NULL);
    pthread_join(tid2, NULL);
    pthread_join(tid3, NULL);
    pthread_join(tid4, NULL);

	//解除字库
	UnInit_Font();
}